function [State] = LandUseClass(ProbEachClass)

N = size(ProbEachClass,1);
K = size(ProbEachClass,2);

Fail = any(sum(ProbEachClass,2) ~= 1);
if Fail
    disp(' Land use shares must sum to one ')
    return
end

RDraw = rand(N,1);
uk = zeros(N,1);
State = zeros(N,1);

for k=1:K
    uk = uk + ProbEachClass(:,k);
    State = State + ( RDraw < uk );
end

end
    
    
